package myjavax.security.sasl;

import java.io.IOException;

public class SaslException extends IOException {
    private Throwable _exception;

    public SaslException(String detail) {
        super(detail);
    }

    public SaslException(String detail, Throwable ex) {
        super(detail);
        if (ex != null) {
            initCause(ex);
        }
    }

    public Throwable getCause() {
        return this._exception;
    }

    public Throwable initCause(Throwable cause) {
        super.initCause(cause);
        this._exception = cause;
        return this;
    }

    public String toString() {
        String answer = super.toString();
        if (this._exception == null || this._exception == this) {
            return answer;
        }
        return new StringBuilder(String.valueOf(answer)).append(" [Caused by ").append(this._exception.toString()).append("]").toString();
    }
}
